<template>
  <div class="approve-task">
    <el-dialog
      title="处理记录"
      :visible.sync="showDialog"
      width="50%"
      :before-close="handleClose"
      @update:showDialog="toggleDialog"
    >
      <flow-chart :detail="detail"></flow-chart>
      <el-table
        ref="tables"
        width="100%"
        height="100%"
        v-loading="loading"
        :data="handleList"
      >
        <el-table-column
          label="审批节点"
          align="center"
          prop="taskActName"
          :show-overflow-tooltip="true"
        />
        <el-table-column label="办理人" align="center" prop="assignee">
        </el-table-column>
        <el-table-column label="办理情况" align="center" prop="approveType" />
        <el-table-column
          label="审批意见"
          align="center"
          prop="comment"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="办理时间"
          align="center"
          prop="startDate"
          :show-overflow-tooltip="true"
        />
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="handleClose">取消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getInstanceHandleList } from "@/api/internalApproval/allApprovals.js";
import FlowChart from "./flowChart";
export default {
  components: {
    FlowChart,
  },
  props: {
    //弹窗显、隐
    showDialog: {
      type: Boolean,
      default: false,
    },
    detail: {
      type: Object,
      required: true,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      handleList: [],
      loading: false,
    };
  },
  watch: {},
  methods: {
    // 弹窗关闭
    handleClose() {
      this.toggleDialog();
    },
    toggleDialog(visible = false) {
      this.$emit("update:showDialog", visible);
    },
    async getInstanceHandleList() {
      this.loading = true;
      const result = await getInstanceHandleList({
        instanceId: this.detail.id
          ? this.detail.id
          : this.detail.processInstanceId,
      });
      this.handleList = result.data;
      this.loading = false;
    },
  },
  created() {},
  mounted() {
    this.getInstanceHandleList();
  },
};
</script>
<style lang="scss" scoped>
</style>
